package com.keon.jianbao.ui.gridviewfragment;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import com.keon.jianbao.AppContext;
import com.keon.jianbao.adapter.ExpertChooseAdapter;
import com.keon.jianbao.adapter.ExpertListAdapter;
import com.keon.jianbao.api.Api;
import com.keon.jianbao.base.BaseActivity;
import com.keon.jianbao.base.BaseGirdViewFragment;
import com.keon.jianbao.base.BaseGridViewAdapter;
import com.keon.jianbao.bean.Expert;
import com.keon.jianbao.bean.ExpertGridList;
import com.keon.jianbao.bean.ListEntity;
import com.keon.jianbao.enu.WebType;
import com.keon.jianbao.ui.activity.WebActivity;

/**
 * Created by keon on 2015/9/24.
 */
public class ExpertListFragment extends BaseGirdViewFragment {

    int size = 8;

    @Override
    protected void sendRequestData() {
        Api.expert_lists(AppContext.getInstance().getProperty("user.code"), mCurrentPage, size, 1, mHandler);
    }

    @Override
    protected ListEntity parseList(String reponseData) {

        ExpertGridList expertGridList = new ExpertGridList(reponseData);

        return expertGridList;
    }

    protected int getPageSize() {
        return size;
    }

    @Override
    protected BaseGridViewAdapter getListAdapter() {
        return new ExpertListAdapter();
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View view) {

    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        Expert expert = (Expert) mAdapter.getData().get(i);
        BaseActivity ba = (BaseActivity) getActivity();

        Bundle bundle = new Bundle();
        bundle.putInt("type", WebType.EXPERT_INTRO.getId());
        bundle.putInt("expert_id", expert.getId());
        ba.jump(WebActivity.class, bundle);
    }
}
